<template>
  <div class="padding-lr20">
    <div class="flex padding-tb40 border-bottom justify-between">
      <div>{{$route.params.title}}</div>
      <div class="flex-grow">
        <input
          style="width: 90%;float:right;"
          :maxlength="pl?20:200"
          class="text-right"
          type="text"
          :placeholder="pl?pl:'单行输入'"
          v-model="value"
        />
      </div>
    </div>

    <div class="margin-t80">
      <div class="sure bg-ff0 text-ff text-center letter-10" @click="sure">保存</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      value: "",
      pl: ""
    };
  },
  mounted() {
    document.querySelector('html').style.backgroundColor = "#ffffff";
    this.value = this.$route.params.value;
    console.log(this.$route)
    /* if (this.$route.params.type == "user_name") {
      this.pl = "请输入6-20位字符";
    } */
  },
  methods: {
    sure() {
      if (!this.value && this.$route.params.notnull == 1) {
        this.$toast("内容不能为空~");
        return false;
      }
      /* if (this.$route.params.type == "user_name") {
        if (this.value.length < 5 || this.value.length > 21) {
          this.$toast(this.pl);
          return false;
        }
      } */
      this.$axios.post( "/wap/personal/editUserInfo", {
        token: window.localStorage.getItem("token"),
        key: this.$route.params.type,
        value: this.value
      }).then(res => {
        this.$toast(res.data.msg);
        if (res.data.code == 0) {
          this.$router.go(-1);
        }
      });
    }
  }
};
</script>
<style>
html {
  background: white;
}
</style>